package com.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.print.DocFlavor.STRING;
import javax.servlet.http.HttpServletRequest;
import javax.swing.text.html.HTMLDocument.HTMLReader.SpecialAction;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.entity.Pets;
import com.entity.User;
import com.service.PetServiceImpl;

@Controller
public class PetController {
	@Resource
	public PetServiceImpl pServiceImpl;
	@RequestMapping("findAllPet")
	public String findAllpet(Model model){
		List<Pets> list=pServiceImpl.findAllPet();
		model.addAttribute("list",list);
		
		return "/findAllPet.jsp";
	}
	@RequestMapping("updataPet/{id}")
	public String findUserById(Model model,@PathVariable int id){
		Pets pet=pServiceImpl.findPetById(id);
		model.addAttribute("pet",pet);
		return "/updatapet.jsp";	
	}
	@RequestMapping(value="updatap",produces = "application/json;charset=UTF-8")
	public String updataPet(Pets p){
	    pServiceImpl.updatePet(p);
		return "findAllPet";
	}
}
